package uniLearn.data;

import java.math.BigDecimal;

public class DetailResult {
	//variable
	private int acId;
	private String submitBy;
	private int msOrder;
	private String name;
	private BigDecimal mark;
	private BigDecimal fullMark;
	private String feedback;
	private String criteria;
	
	//constructor
	public DetailResult(int acId, String submitBy, int msOrder, String name) {
		if(submitBy.isEmpty() || submitBy.length() > Users.NAME_MAX_LENGTH) {
			//error
			return;
		}
		this.submitBy = submitBy;
		this.acId = acId;
		this.msOrder = msOrder;
		this.name = name;
		this.mark = BigDecimal.ZERO;
		this.fullMark = BigDecimal.ZERO;
		this.criteria = "";
		this.feedback = "";
	}
	
	public DetailResult(int acId, String submitBy, int msOrder) {
		this(acId, submitBy, msOrder, "");
	}

	//getter
	/**
	 * @return the acId
	 */
	public int getAcId() {
		return acId;
	}

	/**
	 * @return the submitBy
	 */
	public String getSubmitBy() {
		return submitBy;
	}

	/**
	 * @return the msOrder
	 */
	public int getMsOrder() {
		return msOrder;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @return the mark
	 */
	public BigDecimal getMark() {
		return mark;
	}

	/**
	 * @return the fullMark
	 */
	public BigDecimal getFullMark() {
		return fullMark;
	}

	/**
	 * @return the feedback
	 */
	public String getFeedback() {
		return feedback;
	}

	/**
	 * @return the criteria
	 */
	public String getCriteria() {
		return criteria;
	}

	//Setter
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @param mark the mark to set
	 */
	public void setMark(BigDecimal mark) {
		this.mark = mark == null ? BigDecimal.ZERO : mark;
	}

	/**
	 * @param fullMark the fullMark to set
	 */
	public void setFullMark(BigDecimal fullMark) {
		this.fullMark = fullMark == null ? BigDecimal.ZERO : fullMark;
	}

	/**
	 * @param feedback the feedback to set
	 */
	public void setFeedback(String feedback) {
		this.feedback = feedback == null ? "" : feedback;
	}

	/**
	 * @param criteria the criteria to set
	 */
	public void setCriteria(String criteria) {
		this.criteria = criteria;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + acId;
		result = prime * result
				+ ((criteria == null) ? 0 : criteria.hashCode());
		result = prime * result
				+ ((feedback == null) ? 0 : feedback.hashCode());
		result = prime * result
				+ ((fullMark == null) ? 0 : fullMark.hashCode());
		result = prime * result + ((mark == null) ? 0 : mark.hashCode());
		result = prime * result + msOrder;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result
				+ ((submitBy == null) ? 0 : submitBy.hashCode());
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		DetailResult other = (DetailResult) obj;
		if (acId != other.acId)
			return false;
		if (criteria == null) {
			if (other.criteria != null)
				return false;
		} else if (!criteria.equals(other.criteria))
			return false;
		if (feedback == null) {
			if (other.feedback != null)
				return false;
		} else if (!feedback.equals(other.feedback))
			return false;
		if (fullMark == null) {
			if (other.fullMark != null)
				return false;
		} else if (!fullMark.equals(other.fullMark))
			return false;
		if (mark == null) {
			if (other.mark != null)
				return false;
		} else if (!mark.equals(other.mark))
			return false;
		if (msOrder != other.msOrder)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (submitBy == null) {
			if (other.submitBy != null)
				return false;
		} else if (!submitBy.equals(other.submitBy))
			return false;
		return true;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("DetailResult [acId=");
		builder.append(acId);
		builder.append(", submitBy=");
		builder.append(submitBy);
		builder.append(", msOrder=");
		builder.append(msOrder);
		builder.append(", name=");
		builder.append(name);
		builder.append(", mark=");
		builder.append(mark);
		builder.append(", fullMark=");
		builder.append(fullMark);
		builder.append(", feedback=");
		builder.append(feedback);
		builder.append(", criteria=");
		builder.append(criteria);
		builder.append("]");
		return builder.toString();
	}


}
